<?php 
$query = array(
		'fields' => array('shoprequest.*'),
		'conditions' => array('shoprequest.user_id' => $this->controller->my->id),
		);	
$userinfos = POP::exe('[@@:UM shoprequest][@@:QU find:first]',$query);
$query = array(
		'fields' => array('shopinfo.*'),
		'conditions' => array('shopinfo.id' => $this->controller->my->id),
		);	
$shopinfos = POP::exe('[@@:UM shopinfo][@@:QU find:first]',$query);

$my_shop_info_num = 0;
foreach($shopinfos as $value) {
	$my_shop_info_num++;
}
$shop_open_flg = 0;
$shop_lock_flg = 0;
$shop_pass_flg = 0;
$shop_exist_flg = 0;
if( isset($userinfos['shoprequest']['user_id']) && isset($shopinfos['shopinfo']['id'])){
	$shop_exist_flg = 1;
	if($userinfos['shopinfo']['lock_flg']){
		$shop_lock_flg = $shopinfos['shopinfo']['lock_flg'];
	}	
	if($shopinfos['shopinfo']['open_flg']){
		$shop_open_flg = $shopinfos['shopinfo']['open_flg'];
	}	
	if($userinfos['shoprequest']['status'] !=null && $userinfos['shoprequest']['status'] == 0){
		$shop_pass_flg = 0;
	}else { 
		$shop_pass_flg = 1;
	}	
}

	/* 我的,收到的订单 */
	$query = array(
			'fields' => array('orderinfo.*'),
			'conditions' => array('OR'=>array(array('orderinfo.shop_id' => $this->controller->my->id),array('orderinfo.user_id' => $this->controller->my->id)),'AND'=>array('orderinfo.order_status >'=>'0')),
			);	
	$rs = POP::exe('[@@:UM orderinfo][@@:QU find:all]',$query);	

	$my_order_num = 0;
	$get_order_num = 0;
	$u_order_num = 0;
	$s_order_num = 0;
	foreach($rs as $value) {
		if($value['orderinfo']['shop_id']==$this->controller->my->id) {
			if($value['orderinfo']['order_status']=='3') {
				$u_order_num++;
			}else{
				$get_order_num++;
			}
		}
		if($value['orderinfo']['user_id']==$this->controller->my->id) {
			$my_order_num++;
			if($value['orderinfo']['order_status']=='3') {
				$s_order_num++;
			}
		}
	}
    unset($rs);	
/*  判定是否为供货商*/
	$query = array(
			'fields' => array('supplier.*'),
			'conditions' => array('supplier.sup_user_id' => $this->controller->my->id),
			);	
	$is_distribution = POP::exe('[@@:UM supplier][@@:QU find:first]',$query);		

?>	
        <div class="menuBox">
        	<ul class="first-menu">
            	<li class="hasmore">
                	<a href="#"  class="noheaderurl">我是买家</a>
                	<ul class="second-menu">
                        <li  class="nomore">
                        	<a href="<?php echo $this->_url('user/usermyorder');?>">我的订单</a>
                        </li>	
						
                        <li  class="nomore">
                        	<a href="<?php echo $this->_url('cart/index/');?>">我的购物车</a>
                        </li>						
                        <li  class="nomore">
                        	<a href="<?php echo $this->_url('guestbook/index/');?>">我的留言</a>
                        </li>	
						
                        <li  class="nomore">
                        	<a href="<?php echo $this->_url('user/favorite/?type=pro');?>">收藏的商品</a>
                        </li>	
						
                        <li  class="nomore">
                        	<a href="<?php echo $this->_url('user/favorite/?type=shop');?>">收藏的商铺</a>
                        </li>
                        <li  class="nomore">
                        	<a href="<?php echo $this->_url('user/address');?>">收货地址</a>
                        </li>						
                        <li  class="nomore">
                        	<a href="<?php echo $this->_url('logistics/index');?>">我的物流</a>
                        </li>
                        <li  class="nomore">
                        	<a href="<?php echo $this->_url('custom/uservip');?>">我是VIP客户</a>
                        </li>							
						
                    </ul>
                </li>
			
                <li  class="hasmore">
                	<a href="#"  class="noheaderurl">我是卖家</a>
                	<ul class="second-menu">
					<?php if($shop_exist_flg == 1){?>
						<?php if($shop_pass_flg ==1){?>
						    <?php if($shop_lock_flg == 0){?>
								<li style="position:relative"> 
								<a style="_margin-bottom:-18px" id="shop_info" onclick="menu_style_change('shop_info')"  href="<?php echo $this->_url('user/shopinfo');?>">
									店铺设置
								</a>
								<span id="shop_flg" style="position:absolute;width:37px;right:20px;top:4px;_top:3px"> 
								<?php if($shop_open_flg ==1){?> 
								<label style="color:red; cursor:pointer; font-weight:normal">
								<a href="<?php echo $this->_url('usershop/shopopenflg/?flg=0');?>" >开启</a>
								</label> 
								<?php  } else {?> 
								<label  style="color:red; cursor:pointer; font-weight:normal">
								<a href="<?php echo $this->_url('usershop/shopopenflg/?flg=1');?>">关闭</a>
								</label> 
								<?php }?> </span> 
								</li>
								<li>	
								<a href="<?php echo $this->_url('shop/index/'.$this->controller->my->id);?>" target="_blank">店铺预览</a>
								</li>
								<li>
								<a id="shop_category" onclick="menu_style_change('shop_category')" href="<?php echo $this->_url('goods/categorylist');?>">店铺商品分类</a></li>
								<li>
								<a id="goods_list" onclick="menu_style_change('goods_list')" href="<?php echo $this->_url('goods/ulist');?>">商品管理</a>
								</li>
								
								<li>
								<a id="shop_my_order" onclick="menu_style_change('shop_my_order')" href="<?php echo $this->_url('usershop/shopmyorder');?>">
								收到的订单(<?php echo  $get_order_num;?>)<?php if($get_order_num>0){?>
								<img src="<?php echo $this->_webroot('user/images/woo.gif'); ?>" width="21" height="12" /><?php }?>								
								</a>
								</li>
								<li>
								<a id="shop_guestbook" style="_padding-top:5px;_margin-bottom:-5px" onclick="menu_style_change('shop_guestbook')" href="<?php echo $this->_url('guestbook/shoplist/');?>">
								收到的留言								</a>
								</li>
								<li><a id="shop_notice" onclick="menu_style_change('shop_notice')" href="<?php echo $this->_url('user/shopnotice');?>">店铺公告</a></li>
								<li>
								<a id="shop_payment" onclick="menu_style_change('shop_payment')" href="<?php echo $this->_url('usershop/shoppayment');?>">
								支付方式设置								</a>
								</li>
								<li>
								<a id="shop_receiv_list" onclick="menu_style_change('shop_receiv_list')" href="<?php echo $this->_url('usershop/receivlist');?>">
								收款单
								</a>
								</li>
								<li>
								<a id="shop_shipping_list" onclick="menu_style_change('shop_shipping_list')" href="<?php echo $this->_url('usershop/shippinglist');?>">
								发货单
								</a>
								</li>
								<li>
								<a id="shop_refund_list" onclick="menu_style_change('shop_refund_list')" href="<?php echo $this->_url('usershop/refundlist');?>">
								退款单
								</a>
								</li>
								<li>
								<a id="shop_album_index" onclick="menu_style_change('shop_album_index')" href="<?php echo $this->_url('album/index');?>">
								相册管理
								</a>
								</li>
								<li>
								<a id="shop_shoparticle_index" onclick="menu_style_change('shop_shoparticle_index')" href="<?php echo $this->_url('shoparticle/index');?>">
								文章管理
								</a>
								</li>
								<li>
								<a id="shop_shoplinks_index" onclick="menu_style_change('shop_shoplinks_index')" href="<?php echo $this->_url('shoplinks/index');?>">
								店铺友情链接
								</a>
								</li>
								<li>
								<a id="shop_shopjob_index" onclick="menu_style_change('shop_shopjob_index')" href="<?php echo $this->_url('shopjob/index');?>">
								店铺招聘
								</a>
								</li>								
								
                                <li><a href="<?php echo $this->_url('account/ensure');?>">保障金款项</a></li>								
                                <li><a href="<?php echo $this->_url('account/ranklist');?>">会员等级购买</a></li>								
								<li>
								<a id="shop_album_index" onclick="menu_style_change('shop_supplier_index')" href="<?php echo $this->_url('supplier/index');?>">
								我的供货商
								</a>
								</li>								
                                <li  class="hasmore">
                        	        <a href="#"  class="noheaderurl">客户管理</a>
                                    <ul class="three-menu">
                            	        <li><a href="<?php echo $this->_url('custom/ulist');?>">客户管理</a></li>
                                        <li><a href="<?php echo $this->_url('custom/index');?>">客户等级管理</a></li>
                                     </ul>
                                </li>
                                <li  class="hasmore">
                        	        <a href="#"  class="noheaderurl">团队管理</a>
                                    <ul class="three-menu">
                            	        <li><a href="<?php echo $this->_url('team/department');?>">部门管理</a></li>
                                        <li><a href="<?php echo $this->_url('team/staff');?>">员工管理</a></li>
                            	        <li><a href="<?php echo $this->_url('team/remuneration');?>">薪酬管理</a></li>
                                        <li><a href="<?php echo $this->_url('shopcount/index');?>">员工业绩管理</a></li>	
                                        <li>
										   <a href="<?php echo $this->_url('team/login');?>">
										   <?php if ($this->controller->C_session->read('_user_temp.team.login') =='yes') { ?>切换账户<?php }else{ ?>员工登入<?php } ?>
										   </a>
										</li>
                                        <li><a href="<?php echo $this->_url('team/teampwdlogin/');?>">最高管理员登入</a></li>										
                                        <li><a href="<?php echo $this->_url('team/teampwdedit/');?>">最高管理员密码修改</a></li>										
										<?php if ($this->controller->C_session->read('_user_temp.team.login') =='yes') { ?>
                                        <li><a href="<?php echo $this->_url('team/logout');?>">员工账户退出</a></li>
										<?php } ?>
										
                                     </ul>
                                </li>
                                <li  class="hasmore">
                        	        <a href="#"  class="noheaderurl">进销存管理</a>
                                    <ul class="three-menu">
                            	        <li><a href="<?php echo $this->_url('supplier/index');?>">我要进货</a></li>
                                        <li><a href="<?php echo $this->_url('supplier/index');?>">历史进货</a></li>
                                        <li><a href="<?php echo $this->_url('shopcount/index');?>">销售列表</a></li>	
                                        <li><a href="<?php echo $this->_url('shopcount/stock');?>">进货统计图表</a></li>	
                                        <li><a href="<?php echo $this->_url('shopcount/sell');?>" target="_bank">销售统计图表</a></li>											
                                     </ul>
                                </li>
								
							<?php  } else {?>
								<li><a href="">您的商铺已经被锁定</a></li>
							<?php }?>
						<?php  } else {?>
							<li><a href="">商铺正在审核中</a></li>
						<?php }?>							
					<?php  } else {?>
					    <li  class="nomore"><a href="<?php echo $this->_url('user/shoprequest');?>">申请开店</a></li>
					<?php } ?>	
                    </ul>
                </li>	               
                <li  class="hasmore">
                	<a href="#" class="noheaderurl">评价管理</a>
                	<ul class="second-menu">
                        <li  class="nomore">
                        	<a href="<?php echo $this->_url('usershop/shoprate?t=buyer');?>">来自买家的评价</a>
                        </li>
						<li class="nomore">
                        	<a href="<?php echo $this->_url('usershop/shoprate?t=seller');?>">来自卖家的评价</a>
                        </li>
                        <li  class="nomore">
                        	<a href="<?php echo $this->_url('usershop/shoprate?t=bymain');?>">给他人的评价</a>
                        </li>
                    </ul>
                </li>	
                <?php if ( $is_distribution ) { ?>				
                <li  class="hasmore">
                	<a href="#" class="noheaderurl">我是供货商</a>
                	<ul class="second-menu">
                        <li  class="nomore">
                        	<a href="<?php echo $this->_url('supplier/info');?>">供货商基本设置</a>
                        </li>					
                        <li  class="nomore">
                        	<a href="<?php echo $this->_url('supplier/distribution');?>">分销店铺管理</a>
                        </li>
					
						
                    </ul>
                </li>
			   <?php }?>
                <li  class="hasmore">
                	<a href="#"  class="noheaderurl">账户管理</a>
                	<ul class="second-menu">
                        <li  class="nomore">
                        	<a href="<?php echo $this->_url('account/index');?>">我的账户</a>
                        </li>
                    	<li  class="hasmore">
                        	<a href="#"  class="noheaderurl">资金管理</a>
                            <ul class="three-menu">							
                            	<!--<li><a href="<?php echo $this->_url('account/freeze');?>">冻结款项</a></li>-->
                                <li><a href="<?php echo $this->_url('account/detail');?>">账户明细</a></li>
                                <li><a href="<?php echo $this->_url('account/drawback');?>">申请提款</a></li>
								
                            </ul>
                        </li>
<!--						
						<li class="nomore">
                        	<a href="#">我的积分</a>
                        </li>
                        <li  class="nomore">
                        	<a href="#">站内链接</a>
                        </li>
-->						
                    </ul>
                </li>
                <li  class="hasmore">
                	<a href="#" class="noheaderurl">个人设置</a>
                	<ul class="second-menu">
                        <li  class="nomore">
                        	<a href="<?php echo $this->_url('user/profile');?>">个人信息</a>
                        </li>
                        <li  class="nomore">
                        	<a href="<?php echo $this->_url('remind/index');?>">站内消息</a>
                        </li>						
						<li class="nomore">
                        	<a href="<?php echo $this->_url('user/passwd');?>">修改密码</a>
                        </li>
                        <li  class="nomore">
                        	<a href="<?php echo $this->_url('user/logout');?>">安全退出</a>
                        </li>
                    </ul>
                </li>				
				
            </ul>
        </div>
<script language="JavaScript">
<!--
function change_open_status(flg) {
	if(flg==1){
		var open=confirm('您确定要关闭商铺吗？关闭商铺的时商铺下的商品同时下架！');

		if (open){
			ajax("do.php?act=shop_open_flg","POST","value="+flg,function(return_text){
				return_text = return_text.replace(/[\n\r]/g,"");
				document.getElementById("shop_flg").innerHTML = return_text;
			});
		}
	}else {
		ajax("do.php?act=shop_open_flg","POST","value="+flg,function(return_text){
			return_text = return_text.replace(/[\n\r]/g,"");
			document.getElementById("shop_flg").innerHTML = return_text;
		});
	}
}
function menu_style_change(flg) {
	document.getElementById(flg).className="current";
}
//-->
</script>		